//Name: Sara Thorup
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
void test(int choice);
/*

Unit tests for steward card
Steward allows the player a) draw two cards. b) gain two coins or c) trash two cards 

Things to test:
- player gets two card
- player gets two coins
- player trashes two cards
*/

int main(int argc, char *argv[]) {
	printf("\n ===== Testing Steward card =====\n");
	test(1);
	test(2);
	test(3);
	return 0;
}

void test(int choice) {
	//setup
	struct gameState* gameState = newGame();
	int testPlayer = 0;
	int numPlayers = 2;
	int kingdomCards[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
	int randomSeed = 10;
	if (initializeGame(numPlayers, kingdomCards, randomSeed, gameState) != 0){
		printf("Error initalizing game. \n");
		return;
	}
	int discard1 = 0;
	int discard2 = 0;
	int handPos = 0;
	int bonus = 0;
	int cardsGained = 2;
	int coinsGained = 2;
	int cardsTrashed = 2;

	int initalHandCount = gameState->handCount[testPlayer];
	int initalDeckCount = 15;  //set default deck count
	int initalDiscardCount = 15; //set discard count
	int initalCoins = gameState->coins;

	//fill deck and discard with gold cards
	gameState->deckCount[testPlayer] = initalDeckCount;
	int i = 0;
	for (; i < initalDeckCount; i++) {
		gameState->deck[testPlayer][i] = estate;
	}
	gameState->discardCount[testPlayer] = initalDiscardCount;

	for (i = 0; i < initalDiscardCount; i++) {
		gameState->discard[testPlayer][i] = estate;
	}

	for (i = 0; i < initalHandCount; i++ ){
		gameState->hand[testPlayer][i] = steward;
	}

	cardEffect(steward, choice, discard1, discard2, gameState, handPos, &bonus);

	int newHandCount = gameState->handCount[testPlayer];
	int newCoinCount = gameState->coins;
	if (choice == 1) {
		if (newHandCount == initalHandCount + cardsGained - 1) {
			printf("Steward Card: PASS number of cards in hand incremented  \n"  );
		} else {
			printf("Steward Card: FAIL number of cards in hand  not incremented \n");
		}

		if (gameState->hand[testPlayer][handPos] == estate){
			printf("Steward Card: PASS three new cards were added  \n"  );
		} else {
			printf("Steward Card: FAIL three new cards were not added  \n"  );
			
		}
	} else if (choice ==2) {
		if (newCoinCount == initalCoins + coinsGained) {
			printf("Steward Card: PASS number of coins  incremented  \n"  );
		} else {
			printf("Steward Card: FAIL number of coins incremented \n");
		}		
	} else {
		if (newHandCount == initalHandCount - cardsTrashed - 1) {
			printf("Steward Card: PASS number of cards in hand decremented  \n"  );
		} else {
			printf("Steward Card: FAIL number of cards in hand  not decremented \n");
		}
	}

	
	
}